﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;

namespace NSATBPortal
{
    public partial class RunsJournalHome : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void RunsGrid_RowEditing(object sender, GridViewEditEventArgs e)
        {
            int iIndex = e.NewEditIndex;

            string sRecID = RunsGrid.DataKeys[iIndex].Value.ToString();

            Response.Redirect("RunsJournalView.aspx?ID=" + sRecID.Trim());
        }

        protected void RunsGrid_Init(object sender, EventArgs e)
        {
            DataTable dtResults;
            using (ATBSchemaDB objATBDB = new ATBSchemaDB())
            {
                dtResults = objATBDB.GetRunsJournalList();
            }

            RunsGrid.DataSource = dtResults;
            RunsGrid.DataBind();
        }

        protected void RunsGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int iIndex = e.RowIndex;
            string sRecID = RunsGrid.DataKeys[iIndex].Value.ToString();
            string sUserID = Request.LogonUserIdentity.Name;
            using (ATBSchemaDB objATBDB = new ATBSchemaDB())
            {
                objATBDB.DeleteRunsJournal(Convert.ToInt32(sRecID), sUserID);
            }
            e.Cancel = true;
            Response.Redirect(Request.RawUrl);
        }

    }
}